﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Contracts; 
using KandaAlpha.Application.Interfaces;
using KandaAlpha.Domain.Repository;
using KandaAlpha.Domain.Model.Entities;
using System.Diagnostics.Contracts;

namespace KandaAlpha.UI.Mvc.Tests
{
    public class EntityService<T> : IEntityService<T> where T : EntityBase
    {
        private readonly IGenericRepository<T> _genericRepository;

        public EntityService(IGenericRepository<T> genericRepository) 
        {
            _genericRepository = genericRepository;
        }

        public List<T> GetAll()
        {
            return _genericRepository.GetAll();
        }

        public void Add(T entity)
        {
            _genericRepository.Add(entity);
        }

        public void Update(T entity)
        {
            _genericRepository.Update(entity);
        }

        public void Delete(T entity)
        {
            _genericRepository.Delete(entity);
        }

        public T Load(int entityID)
        {
            return _genericRepository.Load(c => c.ID == entityID);
        }

        public IQueryable<T> GetQuery()
        {
            return _genericRepository.GetQuery();
        }
    }
}
